package lab01.test01;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();

        int[] array = new int[n];

        for (int i = 0; i < n; i++) {
            array[i] = scanner.nextInt();
        }

        int xorResult = 0;
        for (int i = 0; i < n; i++) {
            xorResult ^= array[i];
        }

        int split = 1;
        while ((xorResult & 1) == 0) {

            xorResult >>>= 1;

            split <<= 1;
        }

        int first = 0;
        int second = 0;
        for (int i = 0; i < n; i++) {

            if ((array[i] & split) == 0) {

                first ^= array[i];
            } else {

                second ^= array[i];
            }
        }

        if (first < second) {

            System.out.println(first + " " + second);
        } else {
            System.out.println(second + " " + first);
        }
    }
}
